<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>ajax基本使用</title>

	</head>

	<body>

		<script>
			// ajax 是一套 API 核心提供的类型: XMLHTTPRequest


			// 1. 创建请求体
			var xhr = new XMLHttpRequest()
			
			
		
			xhr.onreadystatechange = function() {
				
				//console.log(this.readyState)
				
				if (this.readyState != 4) return
				
				console.log(this.response)
				
			}
			
			
			// 这是新的方法.可能在旧的浏览器不支持
			xhr.onload = function() {
				
				console.log(this.readyState)
				console.log(this.responseText)
				
			}
			
			
			/**
			 * open(method: String, uri: URIString, async: Boolean, user: String, password: String): void
			 * GET https://omimo.api.juworker.com/api/Goods/getGoodsDetail?goods_id=145&lang=en-us
			 * */
			xhr.open('GET','tempData.php')
			
			
			xhr.send()
			
			
		</script>

	</body>

</html>